{% extends "base_wide_page.html" %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block sub_title %}{% trans "History" %} - {% endblock %}

{% block wide_page_content %}
      <h2>{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Modification History{% endblocktrans %}</h2>

      {% if user_perm == 'rw' %}
      <p class="tip">{% trans "Tip: a snapshot will be generated after modification, which records the library state after the modification."%}</p>
      {% endif %}

        <table class="commit-list">
            <tr>
                <th width="52%">{% trans "Description"%}</th>
                <th width="15%">{% trans "Time" %}</th>
                <th width="15%">{% trans "Modifier"%}</th>
                <th width="18%">{% trans "Operations" %}</th>
            </tr>

            {% for commit in commits %}
            {% if commit.show %}
            <tr>
                <td>
                    {{ commit.props.desc|translate_commit_desc }}
                    {% if page_next or not forloop.last %}
                    <a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ commit.id }}" data-time="{{ commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
                    {% endif %}
                </td>
                <td>{{ commit.ctime|translate_seahub_time }}</td>
                <td>
                {% if commit.creator_name %}
                    {% if not commit.second_parent_id %}
                    <a href="{% url 'user_profile' commit.creator_name %}" class="vam">{{ commit.creator_name|email2nickname }}</a>
                    {% else %}
                    {% trans "None"%}
                    {% endif %}
                {% else %}
                    {% trans "Unknown"%}
                {% endif %}
                </td>
                <td>
                    {% if user_perm == 'rw' %}
                        {% if forloop.first and current_page == 1 %}
                        <span class="op vh">{% trans "Current Version" %}</span>
                        {% else %}
                        <a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op vh">{% trans "View Snapshot" %}</a>
                        {% endif %}
                    {% endif %}
                </td>
            </tr>
            {% endif %}
            {% endfor %}
        </table>
        <div id="paginator">
            {% if current_page != 1 %}
            <a href="?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous"%}</a>
            {% endif %}
            {% if page_next %}
            <a href="?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next"%}</a>
            {% endif %}
            {% if current_page != 1 or page_next %}
            |
            {% endif %}
            <span>{% trans "Per page: "%}</span>
            {% if per_page == 25 %}
            <span> 25 </span>
            {% else %}
            <a href="?per_page=25" class="per-page">25</a>
            {% endif %}
            {% if per_page == 50 %}
            <span> 50 </span>
            {% else %}
            <a href="?per_page=50" class="per-page">50</a>
            {% endif %}
            {% if per_page == 100 %}
            <span> 100 </span>
            {% else %}
            <a href="?per_page=100" class="per-page">100</a>
            {% endif %}
        </div>
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
    {% include 'snippets/list_commit_detail.html' %}
</script>
{% endblock %}
